<?
    $code = '';
    if (isset($_GET['code'])) $code = $_GET['code'];


    if (!$user->validateCode($code)) {
        die('Invalid User Code');
    }

    $r = $bibtex->search('all:');
    $smarty->assign('search_query', $r[2]);        
    $found = $r[0];
    $query = '';
    if ($r[1][0] == '')
    {
        $query = '"'.$r[1][1].'"';
    }
    else
    {
        $query = '"'.$r[1][1].'" (Restricted to '.$r[1][0].')';
    }
    foreach($found as $k=>$v)
    {
        $found[$k]['user'] = $user->getFullname($v['user']);

        foreach ($found[$k] as $ik=>$iv) {
            $found[$k][$ik] = str_replace('\&', '&', $found[$k][$ik]);
            $found[$k][$ik] = str_replace('&', '&amp;', $found[$k][$ik]);
            $found[$k][$ik] = trim($found[$k][$ik]);
        }
    }
    $smarty->assign('results', $found);        
    $smarty->assign('searchQuery', stripslashes($query));

    header("Content-Type: application/xml; charset=ISO-8859-1");
?>
